﻿using MediatR;
using Production_Get.API.Application.Commands.OrderShow;
using Production_Get.API.Infrastructures.Interfaces;
using Return.Enum;
using THE_WIND_RISES.Common.Domans.Warehousing;
using THE_WIND_RISES.Common.Dtos;

namespace Production_Get.API.Application.Commands.Warehousingtes
{
    public class OrderTineManHandler : IRequestHandler<OrderTineManCommend, Result>
    {
        private readonly IBaseRepositoryGet<OrderTine> OrderTine;

        public OrderTineManHandler(IBaseRepositoryGet<OrderTine> OrderTine)
        {
            this.OrderTine = OrderTine;
        }

        public async Task<Result> Handle(OrderTineManCommend request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCodes.Search };

            string sql = "SELECT * FROM OrderTine where OrderTineId=" + request.OrderTineId;
            var list = OrderTine.GetAll(sql, default).FirstOrDefault();
            if (list != null)
            {
                result.Code = (int)CommonErrorCodes.Success;
                result.Data = list;
                result.Msg = "反填成功";
            }

            return result;
        }
    }
}
